package plug

const (
	DefaultVal = int32(1)
)

type TableColumnMap struct {
	TableColumnList []*TableColumns
}

type TableColumns struct {
	TableName   *string
	ColumnNames []*string
}

func TableColumnsToMap(tableColumnMap *TableColumnMap) map[string]map[string]int32 {
	dict := make(map[string]map[string]int32)
	if tableColumnMap == nil {
		return dict
	}

	tableColumns := tableColumnMap.TableColumnList
	for i := 0; i < len(tableColumns); i++ {
		item := tableColumns[i]
		if item == nil {
			continue
		}

		itemMap := make(map[string]int32)
		for _, col := range item.ColumnNames {
			colName := *col
			itemMap[colName] = DefaultVal
		}
		dict[*item.TableName] = itemMap
	}

	return dict
}
